package com.bpz.jxw.article.service.impl;

import com.bpz.jxw.article.dao.NewArticleDao;
import com.bpz.jxw.article.model.NewArticle;
import com.bpz.jxw.article.service.INewArticleService;
import com.bpz.main.model.ActMsg;
import com.bpz.utils.PropCnfg;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * Created by 半瓶子 on 3/2/15.
 * blog: xusir.cnblogs.com
 */
@Service
public class NewArticleService implements INewArticleService {
    @Autowired
    NewArticleDao newArticleDao;

    /**
     * 插入一条新内容
     *
     * @param newArticle
     * @return
     */
    @Override
    public ActMsg insert(NewArticle newArticle) {
        ActMsg msg = new ActMsg();
        msg.setCode(ActMsg.SUCCESS);
        try {
            int res = newArticleDao.insert(newArticle);
            msg.setMsg(PropCnfg.getVal("saveSuccess"));
        } catch (Exception e) {
            msg.setCode(ActMsg.ERROR);
            msg.setMsg(PropCnfg.getVal("saveFail"));
        }
        return msg;
    }
}
